#!/usr/bin/env python3
"""
快速测试修复后的PBPK系统
"""

import sys
import os
import numpy as np

# 添加模块路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

try:
    from src.absorption.absorption_module import AbsorptionModel
    from src.distribution.distribution_module import DistributionModel
    from src.elimination.elimination_module import EliminationModel
    from src.population.population_data import PopulationData
    from src.utils.config_manager import ConfigManager
    
    print("✓ 所有模块导入成功")
    
    # 创建测试配置
    config = ConfigManager('config/example.json')
    params = config.get_model_params()
    
    # 创建时间序列
    time_points = np.linspace(0, 24, 100)
    
    # 创建人群数据
    pop_data = PopulationData()
    default_pop = pop_data.get_default_population()
    individual_params = default_pop['individual_001']
    
    # 测试吸收模块
    abs_model = AbsorptionModel(params)
    abs_result = abs_model.calculate_absorption(individual_params, time_points)
    print("✓ 吸收模块运行成功")
    print(f"  - 吸收结果键: {list(abs_result.keys())}")
    
    # 测试分布模块
    dist_model = DistributionModel(params)
    dist_result = dist_model.calculate_distribution(individual_params, time_points, abs_result)
    print("✓ 分布模块运行成功")
    print(f"  - 分布结果键: {list(dist_result.keys())}")
    
    # 测试消除模块
    elim_model = EliminationModel(params)
    elim_result = elim_model.calculate_elimination(individual_params, time_points, dist_result)
    print("✓ 消除模块运行成功")
    print(f"  - 消除结果键: {list(elim_result.keys())}")
    
    print("\n🎉 所有模块修复完成，可以正常运行PBPK建模系统！")
    print("\n现在可以运行：")
    print("python3 main.py --config config/example.json")
    
except Exception as e:
    print(f"✗ 测试失败: {e}")
    import traceback
    traceback.print_exc()